{% extends 'KickerMainBundle::layout.html.twig' %}

{% block sidebar %}
<ul class="nav nav-list">
    <li class="nav-header"><h5>Match Options</h5></li>
    <li {% if menu == 'display' %} class="active" {% endif %}><a href="{{ path('_game_display') }}">Display matchs</a></li>
    <li {% if menu == 'add' %} class="active" {% endif %}><a href="{{ path('_game_add') }}">Add match</a></li>
</ul>
{% endblock %}

{% block content %}

{% if menu == 'display' %}
<fieldset>
    <legend><h2>List Matchs</h2></legend>
        {% if games %}
    <ul>
            {% for key,game in games %}
            <fieldset>
                <legend> Match {{key+1}}.</legend>
                    {% for key2, team in game.getTeams() %}
                <div class='span3'>
                    <b>Player1: </b>{{team.player1}}
                    <br />
                    <b>Player2: </b>{{team.player2}}
                </div>
                        {% if key2 == 0%}
                <div class='span1'> VS </div>
                        {% endif %}
                    {% endfor %}
                <div class='span2'>
                    <b> Result: </b> {{game.result}}<br />
                    <b> Status: </b>
                            {% if game.status == false%}
                    Pending
                            {% else %}
                    Played
                            {% endif %}
                </div>
                </li>
            </fieldset>
            {% endfor%}
        {% else %}
            <p>There are no matchs</p>
        {% endif %}
    </fieldset>
{% endif %}

{% if menu == 'add' %}
    <form name='add_game' name='add_game' action="{{path('_game_add')}}" method='POST'>
        <fieldset class='span5'>
            <legend><h2>Team1</h2></legend>
            <ul>
        {% for key, team in teams%}
                    <div class='hero-unit'>
                        <div class='row'><input type='radio' name='team1' value="{{team.id}}" checked="checked"/>
                    {{team.player1}} - {{team.email1}}</div>
                            <div class='row'>{{team.player2}} - {{team.email2}}</div>
                        </div>
        {% endfor%}
                    </ul>
                </fieldset>
                <fieldset class='span5'>
                    <legend><h2>Team2</h2></legend>
                    <ul>
        {% for key, team in teams%}
                            <div class='hero-unit'>
                                <div class='row'><input type='radio' name='team2' value="{{team.id}}" checked="checked"/>
                    {{team.player1}} - {{team.email1}}</div>
                                    <div class='row'>{{team.player2}} - {{team.email2}}</div>
                                </div>
        {% endfor%}
                            </ul>
                        </fieldset>
                        <div class='span6'>
                            <button type="submit" class="btn btn-primary">Create Match</button>
                        </div>
                    </form>
{% endif %}

{% endblock %}
